package com.lancoo.edu.platform.operation.backupRestore.init;

import com.lancoo.edu.platform.operation.backupRestore.service.init.BrServerSysInitService;
import com.lancoo.edu.platform.operation.backupRestore.service.timer.ScheduleTask;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

/**
 * @author lzh
 * @date 2024/2/23 17:24
 * @description 系统对应服务器IP重启初始化业务处理
 */
@Slf4j
@Component
@AllArgsConstructor
public class BrServerSysInit implements ApplicationRunner {

    private final BrServerSysInitService brServerSysInitService;
    private final ScheduleTask scheduleTask;

    /**
     * 重启初始化操作
     *
     * @param args 参数
     * @throws Exception 异常
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start("【初始化 系统对应服务器IP】");
        brServerSysInitService.saveServerSysIp();
        // brServerSysInitService.saveServerSysIp_pre();
        stopWatch.stop();
        stopWatch.start("【初始化 定时任务】");
        scheduleTask.initTask();
        stopWatch.stop();
        log.info("【初始化业务处理，耗时：{}】", stopWatch.prettyPrint());
    }
}
